<?php

namespace App\Http\Controllers\Api\v2;

use App\Http\Controllers\ApiController;
use App\Models\BlockItem;

class BlockController extends ApiController
{
    public function index(){

    }

    /**
     * @return \Illuminate\Http\JsonResponse
     */
    public function getItemList(){

        $block_id = intval($this->request->input('block_id'));
        $items = BlockItem::where('block_id', $block_id)->orderBy('displayorder')
            ->get()->map(function ($item){
                $item->image = image_url($item->image);
                return $item;
            });

        return ajaxReturn(['items'=>$items]);
    }
}
